#ifndef _RENDERER_CPP
#define _RENDERER_CPP

#include <iostream>
#include <Windows.h>

/*
use const to replace define
#define HeightMax 75
#define WidthMax 15
*/
const int HeightMax = 75;
const int WidthMax = 15;

class Renderer
{
private:
    /* data */

    char **m_BackBuffer;
    char *m_Row;
    char **m_FrontBuffer;

public:
    //initialize buffer size
    struct Rect
    {
        int Height;
        int Width;
        int x;
        int y;
    };

    Renderer(/* args */);
    ~Renderer();

    void SetBack(char backChar)
    {
    }

    void Draw()
    {
        for (int i = 0; i < HeightMax; i++)
        {
            for (int j = 0; j < WidthMax; j++)
            {
                m_BackBuffer[i][j] = '2';
            }
        }
    }
    void DrawRect(Rect rect)
    {
        // std::cout << "in draw rect" << rect.y << std::endl;
        // std::cout << "rect x " << rect.x << std::endl;

        // std::cout << "Y+Height " << rect.y + rect.Height << std::endl;
        // std::cout << "X+Widht " << rect.x + rect.Width << std::endl;
        for (int i = rect.y; i < rect.Height + rect.y; i++)
        {
            for (int j = rect.x; j < rect.Width + rect.x; j++)
            {
                // std::cout << "setting m_Backffuer" << std::endl;
                m_FrontBuffer[i][j] = '#';
            }
        }
    }

    void DrawFill()
    {
    }

    void DrawStroke()
    {
    }

    void Present()
    {
        m_BackBuffer = m_FrontBuffer;
        for (int i = 0; i < WidthMax; i++)
        {
            for (int j = 0; j < HeightMax; j++)
            {

                std::cout << m_BackBuffer[i][j];
            }
            std::cout << std::endl;
        }
    }

    void Clear()
    {
        for (int i = 0; i < WidthMax; i++)
        {
            for (int j = 0; j < HeightMax; j++)
            {
                m_BackBuffer[i][j] = ' ';
            }
        }
    }

    void DrawLayer()
    {
    }
};

Renderer::Renderer(/* args */)
{

    m_BackBuffer = new char *[WidthMax];
    for (int i = 0; i < WidthMax; i++)
    {
        m_BackBuffer[i] = new char[HeightMax];
        for (int j = 0; j < HeightMax; j++)
        {
            m_BackBuffer[i][j] = ' ';
        }
    }
    m_FrontBuffer = new char *[WidthMax];
    for (int i = 0; i < WidthMax; i++)
    {
        m_FrontBuffer[i] = new char[HeightMax];
        for (int j = 0; j < HeightMax; j++)
        {
            m_FrontBuffer[i][j] = ' ';
        }
    }
}

Renderer::~Renderer()
{
}

#endif
